import request from '@/services/http'

// 获取生境检测折线图
export const getLineData = async (type: string): Promise<any> => {

  const response = await request({
    url: `/euc/data/manager/habitat/getLineData/${type}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })

  return response.data
}

// 获取左侧柱状图数据
export const getBarData = async (): Promise<any> => {

  const response = await request({
    url: `/euc/data/manager/average/getBarData`,
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })

  return response.data
}

// 获取左侧柱状图外部数据（同一月份近三年数据）
export const getBarHomeData = async (): Promise<any> => {

  const response = await request({
    url: `/euc/data/manager/average/getBarHomeData`,
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })

  return response.data
}

// 下载方案
interface DataItem {
  modelType: string;
  markdownContent: string;
}
interface Data {
  data: DataItem[]
}
export const downloadZip = (data: DataItem[]) => {
  return request({
    url: `/euc/download/zip`,
    method: 'post',
    data
  })
}

export const getEchartsData = async (params: { converstionId: string }) => {
  const response = await request({
    url: `/euc/api/chat/echart/get`,
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    params
  })

  return response.data
}

// 获取最新的物候图片地址
export const getPicUrl = async () => {
  const response = await request({
    url: `/euc/data/manager/getPicUrl`,
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })

  return response.data
}

// 获取森林生长设备信息（在线状态）
export const getDevicesInfo = async () => {
  const response = await request({
    url: `/euc/data/manager/getDevicesInfo`,
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })

  return response.data
}

// 获取森林生长设备折线图数据
export const getDeviceLineData = async (id: string) => {
  const response = await request({
    url: `/euc/data/manager/getDeviceLineData/${id}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })

  return response.data
}
